#include"ExecutorImpl.hpp"
#include"Command.hpp"
#include<memory>
#include<map>
#include"Singleton.hpp"
#include"CmderFactory.hpp"
namespace adas {
    Executor* Executor::NewExecutor(const Pose pose) noexcept {
		return new ExecutorImpl(pose);
	}

	ExecutorImpl::ExecutorImpl(const Pose& pose) noexcept : poseManage(pose)
    {

    }

	void ExecutorImpl::Execute(const std::string& commands) noexcept
	{
        const auto cmders = Singleton<CmderFactory>::Instance().GetCmders(commands);
        std::for_each(
            cmders.begin(), cmders.end(),
            [this](const std::function<void(PoseManage& poseManage)>& cmder) noexcept { cmder(this->poseManage); });
    }


	Pose ExecutorImpl::Query(void) const noexcept {
        return this->poseManage.Query();
	}

   

}